﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbPointRef : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbPointRef(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbPointRef_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbPointRef obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbPointRef()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbPointRef(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbPointRef cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbPointRef_cast(OdRxObject.getCPtr(pObj));
			OdDbPointRef result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPointRef_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPointRef_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPointRef_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbPointRef createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbPointRef_createObject();
			OdDbPointRef result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult evalPoint(OdGePoint3d pnt_wcs)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_evalPoint(this.swigCPtr, OdGePoint3d.getCPtr(pnt_wcs));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getEntities(OdDbFullSubentPathArray ents, bool getLastPtRef)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_getEntities__SWIG_0(this.swigCPtr, OdDbFullSubentPathArray.getCPtr(ents), getLastPtRef);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getEntities(OdDbFullSubentPathArray ents)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_getEntities__SWIG_1(this.swigCPtr, OdDbFullSubentPathArray.getCPtr(ents));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isGeomErased()
		{
			bool result = TD_DbPINVOKE.OdDbPointRef_isGeomErased(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isXrefObj(OdDbObjectIdArray ids1, OdDbObjectIdArray ids2, bool isMainObj)
		{
			bool result = TD_DbPINVOKE.OdDbPointRef_isXrefObj__SWIG_0(this.swigCPtr, OdDbObjectIdArray.getCPtr(ids1), OdDbObjectIdArray.getCPtr(ids2), isMainObj);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isXrefObj(OdDbObjectIdArray ids1, OdDbObjectIdArray ids2)
		{
			bool result = TD_DbPINVOKE.OdDbPointRef_isXrefObj__SWIG_1(this.swigCPtr, OdDbObjectIdArray.getCPtr(ids1), OdDbObjectIdArray.getCPtr(ids2));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult updateXrefSubentPath()
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_updateXrefSubentPath(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult updateSubentPath(OdDbIdMapping idMap)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_updateSubentPath(this.swigCPtr, OdDbIdMapping.getCPtr(idMap));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void dwgOutFields(OdDbDwgFiler filer)
		{
			TD_DbPINVOKE.OdDbPointRef_dwgOutFields(this.swigCPtr, OdDbDwgFiler.getCPtr(filer));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void dwgInFields(OdDbDwgFiler filer)
		{
			TD_DbPINVOKE.OdDbPointRef_dwgInFields(this.swigCPtr, OdDbDwgFiler.getCPtr(filer));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void dxfOutFields(OdDbDxfFiler filer)
		{
			TD_DbPINVOKE.OdDbPointRef_dxfOutFields(this.swigCPtr, OdDbDxfFiler.getCPtr(filer));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult dxfInFields(OdDbDxfFiler filer)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPointRef_dxfInFields(this.swigCPtr, OdDbDxfFiler.getCPtr(filer));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void updateDueToMirror(bool inMirror)
		{
			TD_DbPINVOKE.OdDbPointRef_updateDueToMirror__SWIG_0(this.swigCPtr, inMirror);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void updateDueToMirror()
		{
			TD_DbPINVOKE.OdDbPointRef_updateDueToMirror__SWIG_1(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static bool calcTransform(OdDbObjectIdArray ids, OdGeMatrix3d A_Ecs2Wcs)
		{
			bool result = TD_DbPINVOKE.OdDbPointRef_calcTransform(OdDbObjectIdArray.getCPtr(ids), OdGeMatrix3d.getCPtr(A_Ecs2Wcs));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGeMatrix3d mswcsToPswcs(OdDbViewport pVPort)
		{
			OdGeMatrix3d result = new OdGeMatrix3d(TD_DbPINVOKE.OdDbPointRef_mswcsToPswcs(OdDbViewport.getCPtr(pVPort)), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
